#ifndef GLES_DEBUG_H
#define GLES_DEBUG_H

#include "EGL/egl.h"
#include "GLES3/gl3.h"

#include "global.h"
#include <string>
#include <sstream>

#define CHECK(x)										\
	do											\
	{											\
		if (!(x))									\
		{										\
			std::stringstream ss;                                                                 \
            ss << "[ERROR] " << __FILE__ << ":" << __LINE__ << " (" << #x << ") not satisfied\n"; \
            NDK_LOGE("gles_debug", ss.str().c_str());                                             \
		}										\
	} while (0)

#define ASSERT_TRUE_WITH_RETURN_VAL(x, val)                                                       \
    do                                                                                            \
    {                                                                                             \
        if (!(x))                                                                                 \
        {                                                                                         \
            std::stringstream ss;                                                                 \
            ss << "[ERROR] " << __FILE__ << ":" << __LINE__ << " (" << #x << ") not satisfied\n"; \
            NDK_LOGE("gles_debug", ss.str().c_str());                                             \
            return val;								\
		}										\
	} while (0)

void eglCheckError_(const char *file, int line);
#define eglCheckError() eglCheckError_(__FILE__, __LINE__)

#endif